<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>class绑定之字符串形式</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<style>
    .static {
        border: 1px solid black;
        background-color: aquamarine;
    }

    .big {
        width: 200px;
        height: 200px;
    }

    .small {
        width: 100px;
        height: 100px;
    }
</style>

<body>

    <!-- 
     
    -->

    <!-- 准备一个容器 -->
    <div id="app">
        <h1>{{msg}}</h1>
        <!-- 静态写法 -->
        <div class="static small">{{msg}}</div> <br />

        <button @click="changeBig">变大</button>
        <button @click="changeSmall">变小</button>
        <!-- 动态写法：动静都有 -->
        <!-- 适用场景： 如果确认动态绑定的样式只有一个，但是名字不确定 -->
        <div class="static" :class="c1">{{msg}}</div>


    </div>

    <script>

        const vm = new Vue({
            el: '#app',
            data: {
                msg: 'Class绑定之字符串形式',
                c1: 'big'
            },
            methods: {
                changeBig() {
                    this.c1 = 'big'
                },
                changeSmall() {
                    this.c1 = 'small'
                }
            }

        })
    </script>


</body>


</html>